<?
if(!$_SESSION['sid']){
    exit('未登录');
}
require_once("/var/www/html/new/conf/le.je");
$le=new go_sql();
$le->connect();
$s = new SoapClient(null,array(
        "location" => "http://localhost/open/openService/pft_insideMX.php",
        "uri" => "www.16u.com?ac_16u=16ucom|pw_16u=c33367701511b4f6020ec61ded352059|auth_16u=true")
);
$btime = date('Y-m-d').' 00:00:00';
$etime = date('Y-m-d').' 23:59:59';
$total = array();

$xml_1 = $s->Order_Globle_Search( "",$_SESSION['sid'], "", "", "", "", "", "", "", "", "$btime", "$etime", "", "", "", "", "", "", "", "", "0", "1000", "0", "0","","0","0","0","","","","", "","","","0","","");
$sim_1 = simplexml_load_string($xml_1);

$xml_2 = $s->Order_Globle_Search(
    "","", "", "", "", "",  "", "", "", "",
    "$btime", "$etime", "", "", "", "", "", "", "", "",
    "0", "1000", "0", "0","","0","0","0","","",
    $_SESSION['sid'],"", "","","","0","","");
$sim_2 = simplexml_load_string($xml_2);
foreach($sim_1->Rec as $k=>$v){
    //已买到的订单 如果不是自供应的就不统计
    if(!$apply_dids[(int)$v->UUlid]){
        $sql = "select apply_did from uu_land where id=".(int)$v->UUlid;
        $GLOBALS['le']->query($sql);
        $GLOBALS['le']->fetch_assoc();
        $apply_did = $GLOBALS['le']->f('apply_did');
        if($apply_did!=$_SESSION['sid']){
            $apply_dids[(int)$v->UUlid] = 1;
            continue;
        }
        $apply_dids[(int)$v->UUlid] = 2;
    }else if($apply_dids[(int)$v->UUlid] == 1){
        continue;
    }
    total($v);
}
foreach($sim_2->Rec as $k=>$v){
    total($v);
}
function total($v){
    ++$GLOBALS['total']['torder'];
    $GLOBALS['total']['tnum']+=(int)$v->UUtnum;
    if((string)$v->UUaids!='0'){
        $UUaids = (string)$v->UUaids.','.(string)$v->UUmid;
    }else if($v->UUaid!==$v->UUmid){
        $UUaids = (string)$v->UUaid.','.(string)$v->UUmid;
    }else{
        $UUaids = (string)$v->UUaid;
    }
    if((string)$v->UUaids_price != '0'){
        $UUaids_price = (string)$v->UUaids_price.','.(string)$v->UUtprice;
    }else{
        $UUaids_price = (string)$v->UUtprice;
    }
    $UUaids = explode(',', $UUaids);
    $UUaids_price = explode(',', $UUaids_price);
    $key = array_search($_SESSION['sid'],$UUaids);
    $money = $UUaids_price[$key];
    $GLOBALS['total']['money']+=(int)$v->UUtnum*$money;
}
$torder = $GLOBALS['total']['torder']==0? 1: $GLOBALS['total']['tnum']*100;
/*-------------------------页面开头的固定数据--------------------------------*/


$land = array();
$land_json = "{title:'全部产品',id:1},";
include("/var/www/html/new/d/class/Member.php");
$m = new Member($s,$_SESSION['sid']);
$sale = $m->salePros();
foreach($sale as $v){
    $sort[] = mb_substr($v['title'],0,1,'UTF-8');
}
array_multisort($sort,SORT_ASC,$sale);
foreach($sale as $v){
    if(!$land[$v['lid']]){
        $land[$v['lid']]= $v['title'];
        $land_json .="{title:'".$v['title']."',id:".$v['lid']."},";
    }
}

$land_json = rtrim($land_json,',');
echo "<script>
    var lands = {
        status: 'success',
        list: [
            ".$land_json."
        ]
    };
</script>";
/*---------------------------------所有出售的景区---------------------------------*/
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="format-detection" content="telephone=no" />
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<title>数据统计</title>
	<link rel="stylesheet" type="text/css" href="css/map.css"/>
    <script language="javascript" src="http://www.12301.cc/js/jquery-1.9.1.min.js"></script>
	<script src="http://www.12301.cc/js/global/www.12301.cc.global.js"></script>
    <script src="http://www.12301.cc/js/echarts-2.2.1/build/dist/echarts.js"></script>
</head>
<body>
	<div class="topwrapper">
		<div class="topbox">
			<div class="topback"><i class="iconfont icon_back">&#xe60c;</i></div>
			<div class="totle">今日销量（元）<span class="setcolor"><?=$GLOBALS['total']['money']/100?></span></div>
			<div class="databox">
				<span class="data_a">访客：<?=(int)$GLOBALS['total']['tnum']?></span>
				<span class="data_b">订单量：<?=(int)$GLOBALS['total']['torder']?></span>
				<span class="data_c">订单均价:<?=substr($GLOBALS['total']['money']/$torder,0,5)?></span>
			</div>
		</div>
		<div class="linebox">
			<div class="selectonbox">
				<input class="selecton" type="text" readonly value="全部产品"/>
				<input class="search_input" type="text" value="全部产品"/>
				<input type="hidden"  id="lid_id" value="0"/>
				<div class="iconbox">
					<i class="iconfont cleartxt">&#10005; </i>
					<i class="iconfont icon_search">&#xe633;</i>
				</div>
			</div>
			<div class="morebox"><span class="more"></span></div>
		</div>
		<div class="return_txt">返回</div>
		<ul id="suggest_ul"></ul>
		<div class="searchmsg">没有搜索结果</div>
	</div>
	<div class="nonehtml">
	
	
	<div class="mainbox">
		<div id="botFixedmoney" class="botFixedmoney">
			<span class="ticket_num active"  data-line_type="tnum">票数</span>
			<span class="ticket_money" data-line_type="money">金额</span>
		</div>
        <div id="main_a" class="header_map" style="height: 400px"></div>
		<div class="box_a">
			<div class="compass_time">
				<div class="time_css">
					<span class="time_left" data-time_down="<?php echo date("m" , strtotime("-1 month"));?>"><i class="iconfont left_icon">&#xe60c;</i><i class="time_left_num"><?php echo date("m" , strtotime("-1 month"));?></i></span>
					<span class="time_center" data_time="<?php echo date("Y")?>年<?php echo date("m")?>月"><i class="time_center_a"><?php echo date("Y")?></i>年<i class="time_center_b"><?php echo date("m")?></i>月</span>
					<span class="time_right" data-time_add="<?php echo date("m" , strtotime("+1 month"));?>"><i class="time_right_num"><?php echo date("m" , strtotime("+1 month"));?></i><i class="iconfont right_icon">&#xe60d;</i></span>
				</div>
			</div>
			<div id="main_b" class="header_map" style="height: 400px"></div>
		</div>
		<div class="box_b">
			<div class="compass_time">
				<div class="time_css">
					<span class="time_left" data-time_down="<?php echo date("m" , strtotime("-1 month"));?>"><i class="iconfont left_icon">&#xe60c;</i><i class="time_left_num"><?php echo date("m" , strtotime("-1 month"));?></i></span>
					<span class="time_center" data_time="<?php echo date("Y")?>年<?php echo date("m")?>月"><i class="time_center_a"><?php echo date("Y")?></i>年<i class="time_center_b"><?php echo date("m")?></i>月</span>
					<span class="time_right" data-time_add="<?php echo date("m" , strtotime("+1 month"));?>"><i class="time_right_num"><?php echo date("m" , strtotime("+1 month"));?></i><i class="iconfont right_icon">&#xe60d;</i></span>
				</div>
			</div>
		   <div id="main_c" class="header_map" style="height: 400px"></div>
	   </div>
    </div>
    <input type="hidden"  name="ec_type" value="line">
    <input type="hidden"  name="line_type" value="tnum">
    <input type="hidden"  name="lid" value="">
    <input type="hidden"  name="ltitle" value="">
    <div id="botFixedBar" class="botFixedBar">
		<span class="sevenday active" id="se" data-ec_type="line">7日销量</span>
		<span class="channels" data-ec_type="pie">分销渠道</span>
		<span class="source" data-ec_type="map">客源分布</span>
	</div>
	</div>
    <script src="t.js"></script>
    <script src="search.js?v=<?=rand(0,9)?>"></script>
</body>
</html>